package com.cn.wanxi.front;

import com.alibaba.fastjson.JSONObject;
import com.cn.wanxi.model.ProductModel;
import com.cn.wanxi.model.ResultModel;
import com.cn.wanxi.service.ProductService;
import com.cn.wanxi.service.impl.ProductServiceImpl;
import com.cn.wanxi.util.Tool;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/getProductPageCount")
public class ProductPageCountServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String cuisineId=req.getParameter("cuisineId");
        String whereShow = req.getParameter("whereShow");


        ProductModel productModel=new ProductModel();
        productModel.setCuisineId(Tool.stringToInt(cuisineId));
        ProductService productService=new ProductServiceImpl();
        productModel.setWhereShow(Tool.stringToInt(whereShow));


        ResultModel resultModel=productService.getFrontCount(productModel);
        resp.getWriter().println(JSONObject.toJSONString(resultModel));
    }
}
